package models;

import javax.persistence.Entity;

import play.data.validation.*;
import play.db.jpa.Model;

import java.util.*;
import javax.persistence.*;

import play.db.jpa.*;

/**
 * Class Description & Contstractor
 * 
 * @author Ibrahim Kessba
 * @version 2011.0424
 * @category C2 Modles
 * @return None Number of Relations: 1
 */
// TODO Must Review the ERD for the realtionship with other entites

@Entity
public class Relationship extends Model {

	@Required
	private String name;
	@Required
	private boolean assigned;
	@Required
	private Model source;
	@Required
	private Model destination;
	// Relationship #1 Manage between Relationship And User
	// @ManyToOne

	/**
	 * Relationship constructor that creates a relationship among entities/Topics/Tags 
	   takes name, source and destination, and boolean assigned
	 * 
	 * @author Ebtehal Abed
	 * @version 2011.04.25
	 * @category C2S2
	 * @params String name, Model source: either entity, topic or tag, 
	           Model destination: either entity, topic, or tag,
	           boolean assigned: specified whether the relation is assigned or not
	 * @return nothing
	 */

	public Relationship(String name, Model source, Model destination, boolean assigned) {
		this.name = name;
		this.setSource(source);
		this.setDestination(destination);
		this.assigned = assigned;
	}

	public Relationship() {
		source = new Model();
		destination = new Model();
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public boolean isAssigned() {
		return assigned;
	}

	public void setAssigned(boolean assigned) {
		this.assigned = assigned;
	}

	public void setSource(Model source) {
		this.source = source;
	}

	public Model getSource() {
		return source;
	}

	public void setDestination(Model destination) {
		this.destination = destination;
	}

	public Model getDestination() {
		return destination;
	}
}